import request from '@/utils/request'

/**
 * 提交订单评价
 * @param {Object} data 评价数据
 * @returns {Promise} API响应Promise
 */
export function submitEvaluation(data) {
  return request({
    url: '/api/evaluation/add',
    method: 'post',
    data
  })
}

/**
 * 获取订单的评价
 * @param {number} orderId 订单ID
 * @returns {Promise} API响应Promise
 */
export function getOrderEvaluation(orderId) {
  return request({
    url: `/api/evaluation/order/${orderId}`,
    method: 'get'
  })
}

/**
 * 获取用户的评价列表
 * @param {number} userId 用户ID
 * @param {number} page 页码
 * @param {number} size 每页大小
 * @returns {Promise} API响应Promise
 */
export function getUserEvaluations(userId, page = 1, size = 10) {
  return request({
    url: `/api/evaluation/user/${userId}`,
    method: 'get',
    params: { page, size }
  })
}

/**
 * 获取车行的评价列表
 * @param {number} shopId 车行ID
 * @param {number} page 页码
 * @param {number} size 每页大小
 * @returns {Promise} API响应Promise
 */
export function getShopEvaluations(shopId, page = 1, size = 10) {
  return request({
    url: `/api/evaluation/shop/${shopId}`,
    method: 'get',
    params: { page, size }
  })
}

/**
 * 获取车行平均评分
 * @param {number} shopId 车行ID
 * @returns {Promise} API响应Promise
 */
export function getShopAvgScore(shopId) {
  return request({
    url: `/api/evaluation/shop/${shopId}/score`,
    method: 'get'
  })
} 